<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
   <script>
  
    //  var n=0;
    //  while(n<hhb.length){
    //    n++;
    //     console.log(hhb[n]);
    //  }

console.log('----------------');
var arr=[1,2,3,4,5,6];
var sun=0;
for(var i=0;i<arr.length;i++){
    sun +=arr[i];
}
 var s=sun/arr.length;//平均值
console.log(sun,s);//求和
  




//最大值
var arr=[1,2,3,4,5,6];
 var max=arr[0];
 for(var i=1;i<arr.length;i++){
    if(max<arr[i]){
        max=arr[i];
    }
 }
 console.log(max);





 var arr=[1,2,3,4,5,6];
  var str='';
  for(var i=0;i<arr.length;i++){
        str += arr[i]+'-';//变成字符串且前面添加-
  }

  console.log(str);
 </script> 
</body>
</html>